package com.huiquan.analysis.dao;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import javax.annotation.Resource;

import org.springframework.stereotype.Repository;

import com.ibatis.sqlmap.client.SqlMapClient;

@Repository
public class SentenceSnDao extends BaseDao {

	@Resource(name = "sqlMapClient")
	private SqlMapClient sqlMapClient;

	public static final String space = "SENTENCE_SN.";

	public void initUnlabeledSn(Integer type) {
		Map<String, Object> param = new HashMap<>();
		param.put("type", type);

		update(space + "INIT_UNLABELED_SN", param, sqlMapClient);
	}

	@SuppressWarnings("unchecked")
	public List<Map<String, Object>> retriveSn1(Integer type) {
		Map<String, Object> param = new HashMap<>();
		param.put("type", type);

		return (List<Map<String, Object>>) this.list(space + "RETRIEVE_SN1", param, sqlMapClient);
	}

	public void deleteSn2ByType(Integer type) {
		long startTime = System.currentTimeMillis();
		Map<String, Object> param = new HashMap<>();
		param.put("type", type);

		delete(space + "DELETE_SN2_BY_TYPE", param, sqlMapClient);
		logger.info("【Notice】 deleteSn2ByType cost [{}]ms.", System.currentTimeMillis() - startTime);
	}

	public void batchInsertSn2(List<Map<String, Object>> temp) {
		insert(space + "BATCH_INSERT_SN2", temp, sqlMapClient);
	}

	public void updateSn2ValueBySid(long sid) {
		update(space+"UPDATE_SN2_VALUE_BY_SID", sid, sqlMapClient);
	}

}
